<!DOCTYPE html>
<htmllang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
<meta charset="UTF-8">
<title>我的信息</title>
<script type="text/javascript" src="../jquery/jquery-3.5.1.js"></script>
<link href="../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"> 
 <script src="../bootstrap-3.3.7-dist/js/bootstrap.js"></script> 
</head>
<body>
<nav class="navbar navbar-default">
<div class="row">
  <div class="col-xs-12 col-md-8 col-md-offset-1">
  <div class="col-md-1">
  </div>
   <h1 >个人信息页</h1>
   </div>
    
  <div class="col-xs-6 col-md-4"> 

  </div>
</div>
</nav>
<div class="row">
<div class="col-md-2">
   <button id="myinfobtn" class="btn btn-primary btn-lg btn-block">基本信息</button>
   <button id="updatePasswordBtn" class="btn btn-primary btn-lg btn-block">修改密码</button>
    <div style="display:none">
    <h5 sec:authentication="principal.uid" id="uid" name="uid"></h5>
   </div>  
</div>
<div class="col-md-8" id="myinfo" style="display:none">
 <!-- 粘贴招聘信息 -->
  <table  class="table table-bordered">
  <tbody id="recruitment_tbody">
  <tr>
  <td><h4>用户姓名</h4></td>
  <td><h4>注册电话</h4></td>
  <td><h4>注册地点</h4></td>
  <td><h4>违规次数</h4></td>
  <td><h4>使能状态</h4></td>
  <td><h4>封禁状态</h4></td>
  <td><h4>注册时间</h4></td> 
  </tr>
  <tr>
  <td><span sec:authentication="principal.uname" id="uname"></span></td>
  <td><span sec:authentication="principal.utel" id=utel name="utel"></span></td>
  <td><span sec:authentication="principal.diqu"  ></span></td>
  <td><span sec:authentication="principal.fcount" id="fcount" name="fcount" ></span></td>
  <td><span sec:authentication="principal.uenable"  ></span></td>
  <td><span sec:authentication="principal.ulocked"  ></span></td>
  <td><span sec:authentication="principal.time" ></span></td>
  </tr>
  </tbody>
</table>
<div class="jumbotron  row" id="jinggao" style="display:none">
  <div class="col-md-1"></div>
  <div class="col-md-5 alert-danger">
  <h2>notice<span class="glyphicon glyphicon-warning-sign "></span></h2>
  <h2 >规违规次数:</h2>
  <span id="fcountinfo" class="label label-info"></span><br>
  </div>
  <div class="col-md-6">
  <div class="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>警告!</strong> 违规次数超过五次将会被封号，请注意您的求职招聘行为规范
  </div>
  </div>
</div>
</div>

<!-- 修改密码 -->
<div class="modal fade" id="myModalForPassword" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">修改密码</h4>
      </div>
      <div class="modal-body" id="passwordbody">
      <div class="row">
  <div class="col-md-6 col-md-offset-3 ">
  <!-- form表单 -->
<form id="passwordInfo" class="form-horizontal">
  <div class="form-group ">
    <label >请输入旧密码</label>
    <input type="password" class="form-control " id="oldpassword" name="oldpassword" >
  </div>
  <div class="form-group ">
    <label >请输入新密码</label>
    <input type="password" class="form-control " id="newpassword1" name="upassword1" >
  </div>
  <div class="form-group ">
    <label >再输入新密码</label>
    <input type="password" class="form-control " id="newpassword" name="newpassword" >
  </div>
</form>

</div>
</div>
      </div>
      <div class="modal-footer">
        <button  id="SloseCompany"type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id ="updatePassword">修改</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="col-md-2"></div>
</div> 
</body>
<script type="text/javascript">
var uid;
var fcount
$(function(){
	 uid=$("#uid").text();
	 fcount=$("#fcount").text();
	$("#fcountinfo").append("  "+fcount+"次");
	if(fcount>=1){
		$("#jinggao").show();
	}
}); 

$("#myinfobtn").click(function(){
	$("#myinfo").show();
	
})

$("#updatePasswordBtn").click(function(){

	$("#myModalForPassword").modal({
		backdrop:"static"
	});
	
})
$("#updatePassword").click(function(){
	var oldpassword=$("#oldpassword").val();
	var newpassword=$("#newpassword").val();
	var newpassword1=$("#newpassword1").val();
	var utel=$("#utel").text();
	if($.trim(newpassword) == $.trim(newpassword1)){
		$.ajax({
			url:"/user/updatePassword",
			type:"POST",
			data:{utel:utel,oldpassword:oldpassword,newpassword:newpassword},
		    success:function(result){
		    	if(result.code==200){
		    		alert("原始密码错误！");
		    	}else if(result.code==100){
		    		alert(result.msg+"请重新登录");
			    	window.location.href="/login";
		    	}
		    	
		    }
		});
	}else if($.trim(newpassword) != $.trim(newpassword1)){
		alert("两次密码不相同");
	}
	
	
	
})
//修改密码
</script>
</html>